import request from '@/utils/request'

// 登录方法
export function login(userName, password, code, uuid) {
  const data = {
    userName,
    password,
    grantType: undefined,
    clientId: 'PC',
    deviceType: 'PC',
    clientSecret: '12345678'
  }
  return request({
    url: '/auth/oauth/login?code='+code+'&uuid='+uuid,
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/sys/user/getInfo',
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/auth/oauth/logout',
    method: 'post'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}

// 手机号是否注册
export function checkRegister(query) {
  return request({
    url: '/sys/register/checkRegister',
    method: 'get',
    params: query
  })
}

// 短信验证码
export function regSendSms(query) {
  return request({
    url: '/sys/register/regSendSms',
    method: 'get',
    params: query
  })
}

// 获取区县集合
export function getAllInfo(query) {
  return request({
    url: '/sys/base/address/getAllInfo',
    method: 'get',
    params: query
  })
}

// 获取所有地址集合(树形结构)
export function getAllInfoTree(query) {
  return request({
    url: '/sys/base/address/getAllInfoTree',
    method: 'get',
    params: query
  })
}

// 获取所有市集合
export function getAllCityInfo(query) {
  return request({
    url: '/sys/base/address/getAllCityInfo',
    method: 'get',
    params: query
  })
}

// 查询用户列表
export function getUserList(data) {
  return request({
    url: '/sys/user/logiUser/unchecked',
    method: 'post',
    data: data
  })
}

// 编辑服务商信息
export function updateBossEditDept(data) {
  return request({
    url: '/sys/user/logiUser/bossEditDept',
    method: 'post',
    data:data
  })
}

// 服务商启用
export function enableBossDept(deptId) {
  return request({
    url: '/sys/user/logiUser/enableBossDept/'+deptId,
    method: 'post'
  })
}

// 服务商禁用
export function disableBossDept(deptId) {
  return request({
    url: '/sys/user/logiUser/disableBossDept/'+deptId,
    method: 'post'
  })
}


export function serviceUserList(data) {
  return request({
    url: '/sys/user/logiUser/bossRootList',
    method: 'post',
    data: data
  })
}

// 查询部门扩展信息
export function getByDeptIdDetail(deptId) {
  return request({
    url: '/logi/logi/deptExt/getByDeptId/' + deptId,
    method: 'get',
  })
}

export function batchUpdateUserBasic(data) {
  return request({
    url: '/logi/logi/user/batchUpdateUserBasic',
    method: 'post',
    data: data
  })
}

// 更新用户信息
export function updateUserBasic(data) {
  return request({
    url: '/logi/logi/user/updateUserBasic',
    method: 'put',
    data: data
  })
}
